/*-----------------------------------------------------------------------------
	The contents of this file are subject to the Mozilla Public License
	Version 1.1 (the "License"); you may not use this file except in
	compliance with the License.You may obtain a copy of the License at
	http://www.mozilla.org/MPL/MPL-1.1.html
	
	Software distributed under the License is distributed on an "AS IS"
	basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
	License for the specific language governing rights and limitations
	under the License.
	
	The Original Code is Fever Framework code.
	
	The Initial Developer of the Original Code is Romain Ecarnot.
	Portions created by Initial Developer are Copyright (C) 2006
	the Initial Developer. All Rights Reserved.
	
	Contributor(s):
	
	Unless required by applicable law or agreed to in writing, software
	distributed under the License is distributed on an "AS IS" BASIS,
	WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
	See the License for the specific language governing permissions and
	limitations under the License.
-----------------------------------------------------------------------------*/

import com.bourre.events.EventType;

import fever.app.menu.FvContextMenu;
import fever.app.menu.FvContextMenuItem;
import fever.events.AbstractEvent;

/**
 * Event structure for {@link fever.app.menu.FvContextMenu} object.
 * 
 * @see fever.events.AbstractEvent
 * @see fever.app.menu.FvContextMenu
 * @see fever.app.menu.FvContextMenuItem
 * 
 * @author Romain Ecarnot
 */
class fever.app.menu.FvContextMenuEvent extends AbstractEvent
{
	//-------------------------------------------------------------------------
	// Events definition
	//-------------------------------------------------------------------------
	
	/**
	 * Flash Player dispatches the menuItemSelect event when a user selects an 
	 * item from a context menu.
	 */
	public static var onContextItemEVENT : EventType = new EventType( "onContextItem" );
	 
	 /**
	 * Flash Player dispatches the menuSelect event when a user first generates a 
	 * context menu, but before the contents of the context menu are displayed.
	 */
	public static var onContextMenuEVENT : EventType = new EventType( "onContextMenu" );
	
	
	//-------------------------------------------------------------------------
	// Private properties
	//-------------------------------------------------------------------------
	
	private var _menuItem : FvContextMenuItem;
		 
	
	//-------------------------------------------------------------------------
	// Public Properties
	//-------------------------------------------------------------------------
	
	public var mouseTarget;
	
		
	//-------------------------------------------------------------------------
	// Public API
	//-------------------------------------------------------------------------
	
	/**
	 * Creates an event object that contains information about context menu 
	 * events.
	 * 
	 * @param type {@code EventType} - The event type
	 * @param source Event source
	 */
	public function FvContextMenuEvent(type : EventType, source : FvContextMenu, item : FvContextMenuItem )
	{
		super( type, source );
		
		_menuItem = item;
	}
	
	/**
	 * Returns current event target.
	 */
	public function getTarget() : FvContextMenu
	{
		return FvContextMenu( _oT );
	}
	
	/**
	 * Returns current contextual menu.
	 */
	public function getMenu() : FvContextMenu
	{
		return 	FvContextMenu( _oT );
	}
	
	/**
	 * Returns {@link fever.app.menu.FvContextMenuItem} item if event type 
	 * is {@link #onContextItemEVENT}.
	 */
	public function getItem() : FvContextMenuItem
	{
		return _menuItem;	
	}
	
	/**
	 * Creates a copy of the ContextMenuEvent instance.
	 * 
	 * @return {@code ContextMenuEvent} instance
	 */
	public function clone() : FvContextMenuEvent
	{
		return new FvContextMenuEvent(_e, _oT, _menuItem );
	}
}